package com.zhoug.widget.popup;

import android.content.Context;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;


import com.zhoug.widget.R;

import androidx.core.content.ContextCompat;

/**
 * @Author 35574
 * @Date 2020/5/8
 * @Description
 */
public class BasePopupWindow extends PopupWindow {
    private Context mContext;

    public BasePopupWindow(Context context) {
        super(context);
        this.mContext = context;
        //设置默认宽高
        // 防止在部分机型上不显示是因为没有设置宽高,必须2个都设置才行
        setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    }


    @Override
    public void showAsDropDown(View anchor) {
        super.showAsDropDown(anchor);
    }


    /**
     * 设置背景透明
     */
    public void setTransparentBackground() {
        setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.widgets_bg_transparent));
    }

    public Context getContext() {
        return mContext;
    }

}
